<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2021/4/29
  Time: 10:10 上午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

</head>
<body>
    <form action="/boot/param/dd" method="post">
        <input type="text" name="username">
        <input type="date" name="birthday">
        <input type="submit" value="提交">
    </form>

    <hr>
    <form id="loginForm">
        <input type="text" name="username" id="username">
        <input type="text" name="power" id="power">
        <input type="button" id="login_btn" value="提交">
    </form>

    <script src="${path}/plugins/jquery/jquery.min.js"></script>
    <script>
        $(function(){
            $("#login_btn").click(function(){//闭包
                //此处的参数 - key=value
                //快捷的取的方式 - 表单序列化
                //let formValue = $("#loginForm").serialize();
                //alert(formValue);

                //json对象
               let username = $("#username").val();
                let power = $("#power").val();

                let formValue = {"username":username,"power":power};


                //json字符串
                //formValue = JSON.stringify(formValue);//json对象->json字符串

                <%--$.post('${path}/param/logins',formValue,function(data){--%>
                <%--    console.log(data);--%>
                <%--});--%>

                <%--$.post('${path}/param/logins',formValue,function(data){--%>
                <%--    console.log(data);--%>
                <%--})--%>

                $.ajax({
                    type:'post',
                    url:'${path}/param/logins',
                    data:JSON.stringify(formValue),
                    contentType:"application/json; charset=utf-8",
                    success:function(data){
                        console.log(data);
                    }
                })
            })
        })
    </script>
</body>
</html>
